package org.speed.spring.core;

import java.beans.PropertyDescriptor;

import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

public class TestInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter  {

	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		System.out.println("postProcessBeforeInstantiation beanClass=" + beanClass + ",beanName=" + beanName );
		//return new User("zn", "32");
		return super.postProcessBeforeInstantiation(beanClass, beanName);
	}

	@Override
	public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessAfterInstantiation bean=" + bean + ",beanName=" + beanName );
		return super.postProcessAfterInstantiation(bean, beanName);
	}

	@Override
	public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)
			throws BeansException {
		System.out.println("postProcessProperties pvs=" + pvs + ",bean=" + bean + ",beanName=" + beanName );
		return super.postProcessProperties(pvs, bean, beanName);
	}

	@Override
	public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
			String beanName) throws BeansException {
		System.out.println("postProcessPropertyValues pvs=" + pvs + ",bean=" + bean + ",beanName=" + beanName );
		return super.postProcessPropertyValues(pvs, pds, bean, beanName);
	}

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessBeforeInitialization bean=" + bean +  ",beanName=" + beanName );
		
		return new User("zn", "32");
		//return super.postProcessBeforeInitialization(bean, beanName);
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessAfterInitialization bean=" + bean +  ",beanName=" + beanName );
		return super.postProcessAfterInitialization(bean, beanName);
	}

	
	
}
